use super::*;
use clap::{Parser, Subcommand};

pub mod fetch_training;
pub use fetch_training::*;

pub mod write_book;
pub use write_book::*;

#[derive(Subcommand, Clone, Debug)]
pub enum Commands {
    FetchTraining(FetchTrainingArgs),
    WriteBook(WriteBookArgs),
}

#[derive(Parser, Debug, Clone)]
pub struct CommonArgs {}

#[derive(Parser)]
#[command(version, about, author)]
pub struct CliArgs {
    #[command(flatten)]
    common: CommonArgs,
    #[command(subcommand)]
    commands: Commands,
}

impl CliArgs {
    pub async fn run(self) -> eyre::Result<()> {
        let CliArgs { common, commands } = self;
        match commands {
            Commands::WriteBook(args) => args.run().await,
            Commands::FetchTraining(args) => args.run(&common).await,
        }
    }
}
